//
//  SlowLiveListItemView.m
//  DuTe
//
//  Created by Gikki Ares on 2021/8/4.
//  Copyright © 2021 vgemv. All rights reserved.
//

#import "SlowLiveItemView.h"
#import <JsUtilitySdk/Js_ImageViewWebManager.h>
#import <JsUtilitySdk/JsColorManager.h>
#import "GlobalModel.h"

@interface SlowLiveItemView()

@property (weak, nonatomic) IBOutlet UIImageView *miv;
@property (weak, nonatomic) IBOutlet UILabel *mlb;

@end

@implementation SlowLiveItemView

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setVm:(JsMenuItemVm *)vm {
	_vm = vm;
	[self setupUi];
}

- (void)setupUi {
	_mlb.text = self.vm.title;
	NSURL * url = [NSURL URLWithString:self.vm.imageUrl];
	[_miv js_setImageWithUrlString:url placeholderImage:[GlobalModel sharedInstance].placeholderImage];
//			[_miv sd_setImageWithURL:url placeholderImage:[GlobalModel sharedInstance].placeholderImage];
	
	self.layer.cornerRadius = 8;
	
	UIColor * grayColor = [UIColor colorMax255WithR:200 g:200 b:200 a:200];
	UIColor * orangeColor = [UIColor colorMax255WithR:200 g:200 b:100 a:200];
	
	if(_vm.isSelected) {
		self.layer.borderWidth = 2;
		self.layer.borderColor = orangeColor.CGColor;
		_mlb.backgroundColor = orangeColor;
	}
	else {
		self.layer.borderWidth = 1;
		self.layer.borderColor = grayColor.CGColor;
		_mlb.backgroundColor = grayColor;
	}
}

@end
